// Data.java

package com.ruoyi.service.entity.order;

import com.ruoyi.service.domain.ServiceOrders;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

@lombok.Data
public class PCOrderListRet {
    private Long orderId;
    private String orderIdVO;
    private String orderPayId;
    //private Long userId;
    //private String username;

    private String orderCode;
    private String orderStatus;

    private String orderCodeError;
    private String orderError;

    private String orderCreateTime;
    private String appointmentName;

    private List<PCOrderInfo> orderInfo;
    private PCServeInfo serveInfo;
    private List<PCNurseInfo> nurseInfo;

    private PCPrepaid prePaid;
    private Boolean preFlag = false;
    private PCActual actual;
    private Boolean actFlag = false;
    private PCDifference difference;

    private Long totalAmount;


    private List<PCOrderButton> buttons;

    private String orderPayTip = "";
    private String orderProcessTip = "";

    public void init(ServiceOrders order) {
        this.orderId = order.getOrderId();
        this.orderIdVO = order.getOrderCode();
        DateFormat cstFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String creatTimeNew = cstFormate.format(order.getOrderCreateTime());
        this.orderCreateTime = creatTimeNew;
        this.appointmentName = order.getOrderCreateBy();

        if (order.getOrderPay() != null){
            this.orderPayId = order.getOrderPay().toString();
            this.preFlag = true;
        }
        if (order.getOrderServiceflag() >= 12){
            this.actFlag = true;
        }

        switch (order.getOrderServiceflag()){
            case 3:
            case 5:
            case 6:
            case 7:
                this.setOrderCode("new");
                this.setOrderStatus("新订单");
                break;
            case 8:
                this.setOrderCode("unserved");
                this.setOrderStatus("待服务");
                break;
            case 9:
            case 10:
            case 11:
                this.setOrderCode("serving");
                this.setOrderStatus("服务中");
                break;
            case 12:
            case 13:
                this.setOrderCode("unsettled");
                this.setOrderStatus("结算中");
                break;
            case 14:
            case 15:
                this.setOrderCode("finish");
                this.setOrderStatus("订单完成");
                break;
            //case 16:
            //case 17:
            //    this.setOrderCode("settled");
            //    this.setOrderStatus("已结算");
            //    break;
            case 2:
                this.setOrderCode("canceled");
                this.setOrderStatus("已退单");
                break;
            case 4:
                this.setOrderCode("canceled");
                this.setOrderStatus("已退单");
                break;
        }
        if("1".equals(order.getOrderUseFlag())){
            this.setOrderCode("unpaid");
            this.setOrderStatus("待付款");
        }
        if((order.getOrderFlag() == 1) || (order.getOrderFlag() == 3) || (order.getOrderFlag() == 4)){
            this.setOrderCode("canceled");
            this.setOrderStatus("已取消");
        }

        if (order.getOrderStatus() != 0){
            switch (order.getOrderStatus()){
                case 1:
                    this.setOrderCodeError("otSend");
                    this.setOrderError("超时预警(派单)");
                    break;
                case 2:
                    this.setOrderCodeError("otAccept");
                    this.setOrderError("超时预警(接单)");
                    break;
                case 3:
                    this.setOrderCodeError("otStart");
                    this.setOrderError("超时未开始");
                    break;
                case 4:
                    this.setOrderCodeError("otEnd");
                    this.setOrderError("超时未结束服务");
                    break;
                case 5:
                    this.setOrderCodeError("otCheck");
                    this.setOrderError("超时未提交结算");
                    break;
                case 6:
                    this.setOrderCodeError("otEndPay");
                    this.setOrderError("超时未结算尾款");
                    break;
            }
        }
    }


}